fix: solve #3504 — clear WebGL texture atlas on terminal reattach/resize#3505
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
fix: solve #3504 — clear WebGL texture atlas on terminal reattach/resize#3505github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
Stale glyph textures in the xterm WebGL addon cause garbled rendering and ghosting on macOS when a cached terminal is reattached to a DOM container (tab switch) or resized. Expose clearTextureAtlas() from the WebGL addon and call it in attachToContainer before refresh, and in the ResizeObserver when dimensions change. Refs xtermjs/xterm.js#3303. Closes #3504
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
attachToContainerinv1-terminal-cache.tscallsxterm.refresh()but never clears the WebGL texture atlas. Stale glyph textures from the previous rendering context persist, causing garbled text and background terminal content ghosting into the chat view on macOS.clearTextureAtlas()from the xtermWebglAddonviacreateTerminalInWrapper()inhelpers.ts, store it inCachedTerminal, and call it inattachToContainerbeforerefresh()and in theResizeObservercallback when dimensions change. This forces the WebGL renderer to rebuild its glyph texture from scratch on every reattach/resize, eliminating stale rendering artifacts.v1-terminal-cache.test.tswith 5 tests that model the attach/resize logic and verifyclearTextureAtlasis called at the right times (before refresh on reattach, on resize when dimensions change, not on no-op resize).Test plan
bun test apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/— all 73 tests pass (including 5 new)bun run lint:fix— passes cleanCloses #3504
Summary by cubic
Fixes issue #3504 by clearing the xterm WebGL texture atlas when a cached terminal is reattached or resized. This removes stale glyphs and prevents garbled text and ghosting on macOS.
clearTextureAtlasfromWebglAddonviacreateTerminalInWrapper, store onCachedTerminal.clearTextureAtlas()inattachToContainerbeforerefresh()and onResizeObserverdimension changes.Written for commit 09b38ac. Summary will update on new commits.